package com.ecelin.service;

import com.ecelin.entities.KeyValue;
import com.ecelin.utils.TemplateUtils;

import java.io.File;

/**
 * @author ecelin@ecelin.com
 */
public class Generate {
	public static void makeFile(KeyValue keyValue) throws Exception {
		TemplateUtils.convert("1.model.entities.entity.ftl", new File(keyValue.getMainClassPath(), "model/entities"), keyValue.getClassName() + ".java", keyValue);
		TemplateUtils.convert("2.mapper.mapper.ftl", new File(keyValue.getMainClassPath(), "mapper"), keyValue.getClassName() + "Mapper.java", keyValue);
		TemplateUtils.convert("3.model.dto.className.addDto.ftl", new File(keyValue.getMainClassPath(), "model/dto/" + keyValue.getCamelClassName()), keyValue.getClassName() + "AddDto.java", keyValue);
		TemplateUtils.convert("4.model.dto.className.pageDto.ftl", new File(keyValue.getMainClassPath(), "model/dto/" + keyValue.getCamelClassName()), keyValue.getClassName() + "PageDto.java", keyValue);
		TemplateUtils.convert("5.model.vo.className.vo.ftl", new File(keyValue.getMainClassPath(), "model/vo/" + keyValue.getCamelClassName()), keyValue.getClassName() + "Vo.java", keyValue);
		TemplateUtils.convert("6.service.service.ftl", new File(keyValue.getMainClassPath(), "service/"), keyValue.getClassName() + "Service.java", keyValue);
		TemplateUtils.convert("7.service.service.impl.ftl", new File(keyValue.getMainClassPath(), "service/impl/"), keyValue.getClassName() + "ServiceImpl.java", keyValue);
		TemplateUtils.convert("8.controller.controller.ftl", new File(keyValue.getMainClassPath(), "controller"), keyValue.getClassName() + "Controller.java", keyValue);
		TemplateUtils.convert("9.common.Constant.ftl", new File(keyValue.getMainClassPath(), "common"), "Constant.java", keyValue);
		TemplateUtils.convert("10.common.KeyValue.ftl", new File(keyValue.getMainClassPath(), "common"), "KeyValue.java", keyValue);
		TemplateUtils.convert("11.common.HttpCode.ftl", new File(keyValue.getMainClassPath(), "common"), "HttpCode.java", keyValue);
		TemplateUtils.convert("12.common.PageQuery.ftl", new File(keyValue.getMainClassPath(), "common"), "PageQuery.java", keyValue);
		TemplateUtils.convert("13.common.ResponseResult.ftl", new File(keyValue.getMainClassPath(), "common"), "ResponseResult.java", keyValue);
		TemplateUtils.convert("14.config.HttpMsgConvertor.ftl", new File(keyValue.getMainClassPath(), "config"), "HttpMsgConvertor.java", keyValue);
		TemplateUtils.convert("15.config.MetaObjectConfig.ftl", new File(keyValue.getMainClassPath(), "config"), "MetaObjectConfig.java", keyValue);
		TemplateUtils.convert("16.config.MybatisPlusConfig.ftl", new File(keyValue.getMainClassPath(), "config"), "MybatisPlusConfig.java", keyValue);
		TemplateUtils.convert("17.config.StringConfig.ftl", new File(keyValue.getMainClassPath(), "config"), "StringConfig.java", keyValue);
		TemplateUtils.convert("18.config.SwaggerConfig.ftl", new File(keyValue.getMainClassPath(), "config"), "SwaggerConfig.java", keyValue);
		TemplateUtils.convert("19.exception.Asserts.ftl", new File(keyValue.getMainClassPath(), "exception"), "Asserts.java", keyValue);
		TemplateUtils.convert("20.exception.CustomizeException.ftl", new File(keyValue.getMainClassPath(), "exception"), "CustomizeException.java", keyValue);
		TemplateUtils.convert("21.exception.GlobalExceptionHandler.ftl", new File(keyValue.getMainClassPath(), "exception"), "GlobalExceptionHandler.java", keyValue);
		TemplateUtils.convert("22.filter.CustomizeFilter.ftl", new File(keyValue.getMainClassPath(), "filter"), "CustomizeFilter.java", keyValue);
		//TemplateUtils.convert("23.utils.DateUtils.ftl", new File(keyValue.getMainClassPath(), "utils"), "DateUtils.java", keyValue);
		//TemplateUtils.convert("24.utils.Md5Utils.ftl", new File(keyValue.getMainClassPath(), "utils"), "Md5Utils.java", keyValue);
		TemplateUtils.convert("25.MainApplication.ftl", keyValue.getMainClassPath(), "MainApplication.java", keyValue);
		TemplateUtils.convert("26.application.ftl", keyValue.getResourcesPath(), "application.yaml", keyValue);
		TemplateUtils.convert("27.pom.ftl", keyValue.getProjectPath(), "pom.xml", keyValue);
		TemplateUtils.convert("28.test.ServiceTest.ftl", keyValue.getTestClassPath(), keyValue.getClassName() + "ServiceTest.java", keyValue);
		TemplateUtils.convert("29.resource.sql.sql.ftl", new File(keyValue.getResourcesPath(), "sql-files"), keyValue.getTableName() + ".sql", keyValue);
		TemplateUtils.convert("30.resource.mybatis.mapper.xml.ftl", new File(keyValue.getResourcesPath(), "mybatis"), keyValue.getClassName() + "Mapper.xml", keyValue);
		TemplateUtils.convert("31.resource.logback.xml.ftl", keyValue.getResourcesPath(), "logback.xml", keyValue);
		TemplateUtils.convert("32.project.gitignore.ftl", keyValue.getProjectPath(), ".gitignore", keyValue);
		TemplateUtils.convert("33.html.index.html.ftl", new File(keyValue.getResourcesPath(),"html"), "index.html", keyValue);
		//TemplateUtils.convert("34.config.redis.RedisConfig.ftl", new File(keyValue.getMainClassPath(),"config/redis"), "RedisConfig.java", keyValue);
		//TemplateUtils.convert("35.config.redis.RedisKeyExpiration.ftl", new File(keyValue.getMainClassPath(),"config/redis"), "RedisKeyExpiration.java", keyValue);
		//TemplateUtils.convert("36.config.redis.RedisListenerConfig.ftl", new File(keyValue.getMainClassPath(),"config/redis"), "RedisListenerConfig.java", keyValue);
	}
}